package kubayaxi.video.client.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import kubayaxi.video.client.request.video.AddVideoRecordDTO;
import kubayaxi.video.mybatis.customize.model.video.dto.DeleteVideoDTO;
import kubayaxi.video.mybatis.customize.model.video.dto.GetIndexVideoDTO;
import kubayaxi.video.mybatis.customize.model.video.dto.GetPublishListDTO;
import kubayaxi.video.mybatis.customize.model.video.dto.GetRelatedVideoDTO;
import kubayaxi.video.client.request.video.ChangeFollowStatusDTO;
import kubayaxi.video.client.request.video.ChangeLikeStatusDTO;
import kubayaxi.video.client.request.video.GetVideoInfoDTO;
import kubayaxi.video.client.service.IVideoService;
import kubayaxi.video.client.response.video.GetVideoInfoVO;
import kubayaxi.video.mybatis.customize.model.video.vo.GetPublishListVO;
import kubayaxi.video.mybatis.customize.model.video.vo.GetRelatedVideoVO;
import kubayaxi.video.service.base.common.request.BaseRequest;
import kubayaxi.video.mybatis.customize.model.video.vo.GetIndexVideoVO;
import kubayaxi.video.service.base.common.response.ResponseResult;
import kubayaxi.video.service.base.common.vo.CommonPageResult;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/client/video")
@Api(tags = "客户端【视频】")
public class VideoController {
    @Resource
    private IVideoService videoService;

    @ApiOperation("获取首页推荐列表数据")
    @PostMapping("/getIndexVideo")
    public ResponseResult<List<GetIndexVideoVO>> getIndexVideo(@RequestBody BaseRequest<GetIndexVideoDTO> dto){
        List<GetIndexVideoVO> ans = videoService.getIndexVideo(dto);
        return ResponseResult.success(ans);
    }

    @ApiOperation("根据视频id获取视频详情")
    @PostMapping("/getVideoInfo")
    public ResponseResult<GetVideoInfoVO> getVideoInfo(@RequestBody BaseRequest<GetVideoInfoDTO> dto){
        GetVideoInfoVO ans = videoService.getVideoInfo(dto);
        return ResponseResult.success(ans);
    }

    @ApiOperation("修改关注状态")
    @PostMapping("/changeFollowStatus")
    public ResponseResult changeFollowStatus(@RequestBody BaseRequest<ChangeFollowStatusDTO> dto){
        videoService.changeFollowStatus(dto);
        return ResponseResult.success();
    }

    @ApiOperation("修改喜欢状态")
    @PostMapping("/changeLikeStatus")
    public ResponseResult changeLikeStatus(@RequestBody BaseRequest<ChangeLikeStatusDTO> dto) {
        videoService.changeLikeStatus(dto);
        return ResponseResult.success();
    }

    @ApiOperation("获取相关视频推荐列表")
    @PostMapping("/getRelatedVideo")
    public ResponseResult<List<GetRelatedVideoVO>> getRelatedVideo(@RequestBody BaseRequest<GetRelatedVideoDTO> dto) {
        List<GetRelatedVideoVO> ans = videoService.getRelatedVideo(dto);
        return ResponseResult.success(ans);
    }

    @ApiOperation("添加用户观看视频记录以及增加视频播放量")
    @PostMapping("/addVideoRecord")
    public ResponseResult addVideoRecord(@RequestBody BaseRequest<AddVideoRecordDTO> dto) {
        videoService.addVideoRecord(dto);
        return ResponseResult.success();
    }

    @ApiOperation("删除视频")
    @PostMapping("/deleteVideo")
    public ResponseResult deleteVideo(@RequestBody BaseRequest<DeleteVideoDTO> dto) {
        videoService.deleteVideo(dto);
        return ResponseResult.success();
    }

    @ApiOperation("获取发布列表")
    @PostMapping("/getPublishList")
    public ResponseResult<CommonPageResult<GetPublishListVO>> getPublishList(@RequestBody BaseRequest<GetPublishListDTO> dto) {
        CommonPageResult<GetPublishListVO> ans = videoService.getPublishList(dto);
        return ResponseResult.success(ans);
    }
}
